﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;

namespace NotifyCenter;

public class NotifyCenterDesignTimeFactory : IDesignTimeDbContextFactory<NotifyCenterMigrateDbContext>
{
    public NotifyCenterMigrateDbContext CreateDbContext(string[] args)
    {
        var configuration = new ConfigurationBuilder()
            .AddUserSecrets(typeof(NotifyCenterDesignTimeFactory).Assembly)
            .Build();
        var connectionString = configuration.GetConnectionString("NotifyCenter");

        var optionsBuilder = new DbContextOptionsBuilder();
        optionsBuilder.UseNpgsql(connectionString);

        return new NotifyCenterMigrateDbContext(optionsBuilder.Options);
    }
}
